package com.pzb.order.service.impl;

import com.pzb.order.domain.OdOrder;
import com.pzb.order.domain.OdOrderDetail;
import com.pzb.order.mapper.OdOrderDetailMapper;
import com.pzb.order.service.IOdOrderDetailService;
import com.pzb.order.service.IOdOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 订单详情Service业务层处理
 * 
 * @author Mr_Wu
 * @date 2021-12-15
 */
@Service
public class OdOrderDetailServiceImpl implements IOdOrderDetailService 
{
    @Autowired
    private OdOrderDetailMapper odOrderDetailMapper;
    @Autowired
    private IOdOrderService odOrderService;

    /**
     * 查询订单详情
     * 
     * @param id 订单详情主键
     * @return 订单详情
     */
    @Override
    public OdOrderDetail selectOdOrderDetailById(Long id)
    {
        OdOrderDetail orderDetail = odOrderDetailMapper.selectOdOrderDetailById(id);
        OdOrder order = odOrderService.selectOdOrderByOrderCode(orderDetail.getOrderCode());
        orderDetail.setOrder(order);
        return orderDetail;
    }

    /**
     * 新增订单详情
     *
     * @param odOrderDetail 订单详情
     * @return 结果
     */
    public int insertOdOrderDetail(OdOrderDetail odOrderDetail){
        return odOrderDetailMapper.insertOdOrderDetail(odOrderDetail);
    };

    /**
     * 修改订单详情
     * 
     * @param odOrderDetail 订单详情
     * @return 结果
     */
    @Override
    public int updateOdOrderDetail(OdOrderDetail odOrderDetail)
    {
        return odOrderDetailMapper.updateOdOrderDetail(odOrderDetail);
    }

    /**
     * 根据订单编号查询订单详情
     *
     * @param orderCode 订单编号
     * @return 结果
     */
    @Override
    public List<OdOrderDetail> selectOdOrderDetailByOrderCode(String orderCode) {
        return odOrderDetailMapper.selectOdOrderDetailByOrderCode(orderCode);
    }

    @Override
    public List<OdOrderDetail> selectServiceDetailList(String extAppid, String openid, String serviceStatus) {
        return odOrderDetailMapper.selectServiceDetailList(extAppid,openid,serviceStatus);
    }


}
